package com.dingyang.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({MinIOProperties.class})
public class MinIOConfig {

    @Autowired
    private MinIOProperties properties;

    @Bean
    public MinioClient getMinioClient(){
        return MinioClient.builder()
                .endpoint(properties.getUrl())
                .credentials(properties.getAccessKey(),properties.getSecretKey())
                .build();
    }
    //扩展
    // 桶是否存在，不存在的话，创建指定的桶，并将一些桶的默认配置在这里进行配置。
}
